package com.sharon.sharon_note.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.sharon.sharon_note.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api(tags = "测试接口")
@RequestMapping("/test")
public class TestController {
    @GetMapping("/hello")
    @ApiOperation("test hello")
    @ApiOperationSupport(order = 1)
    public JsonResult hello() {
        log.info("test1:hello");
        return JsonResult.success("hello");
    }

    @GetMapping("/exception")
    @ApiOperation("test exception")
    @ApiOperationSupport(order = 2)
    public JsonResult exception(Integer state) throws Exception {
        log.info("test2:" + state);
        if (state < 5) throw new Exception("error state");
        return JsonResult.success();
    }
}
